﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>StringContainer</h3>
    <p>
        <b>1.代替String类型实现.net基本类型转换。</b><br/>
        支持的类型为：SByte,Byte,Int16,UInt16,Int32,UInt32,Int64,UInt64,Boolean,<br />
        Char,Decimal,Double,Single,DateTime,DateTimeOffset，<br/>
        SByte?,Byte?,Int16?,UInt16?,Int32?,UInt32?,Int64?,UInt64?,Boolean?,<br />
        Char?,Decimal?,Double?,Single?,DateTime?,DateTimeOffset?<br />
        <pre class="brush:csharp">
            using NFinal;
            public class IndexController : BaseController
            {
                public void Index()
                {
                    StringContainer str="12";
                    //自动转换功能，比原生string字符串是不是好用得多？
                    //如果转换失败，number值将为默认值0
                    int number=str;
                }
            }
        </pre>
    </p>
    <b>2.在NFinal中的应用</b>
    <pre class="brush:csharp">
        using NFinal;
        public class IndexController : BaseController
        {
            public void Index()
            {
                //parameters的类型是FastDictionary&lt;string,StringContainer>类型
                //以前我们需要手动转换，而且还要判断转换是否成功，现在则简单多了。
                int age=this.parameters["age"];
                DateTime birthday=this.parameters["birthday"];
                string name=this.parameters["name"];
            }
        }
    </pre>
</body>
</html>